import { defineStore } from 'pinia';
import { ref } from 'vue';

interface ChartData {
  name: string;
  value: number;
}

export const useDashboardStore = defineStore('dashboard', () => {
  const chartData = ref<ChartData[]>([]);  // 图表数据
  const stats = ref<{ [key: string]: number }>({
    totalUsers: 0,
    totalVisits: 0,
  });  // 统计卡片数据

  // 更新图表数据
  const setChartData = (data: ChartData[]) => {
    chartData.value = data;
  };

  // 更新统计数据
  const setStats = (newStats: { [key: string]: number }) => {
    stats.value = newStats;
  };

  return {
    chartData,
    stats,
    setChartData,
    setStats,
  };
});
